import time

import pytest
from selenium import webdriver

from .tabs import Tabs
from ...common.ui.Selector import Selector
from ...exception.TestException import TestException


def test_tbas_antd3x():
    browser = webdriver.Chrome()
    browser.maximize_window()
    browser.get("https://3x.ant.design/components/tabs-cn/")

    # 基本
    tabs = Tabs(browser,
                  '//section[@id="components-tabs-demo-basic"]/section//div[@role="tablist"]',
                  Selector.XPATH)
    tabs.setValue('Tab 3')

    # 禁用
    tabs = Tabs(browser,
                '//section[@id="components-tabs-demo-disabled"]/section//div[@role="tablist"]',
                Selector.XPATH)
    with pytest.raises(TestException):
        tabs.setValue('Tab 2')

    # 图标
    tabs = Tabs(browser,
                '//section[@id="components-tabs-demo-icon"]/section//div[@role="tablist"]',
                Selector.XPATH)
    tabs.setValue('Tab 2')

    # 滑动
    # 有问题啊
    # tabs = Tabs(browser,
    #             '//section[@id="components-tabs-demo-slide"]/section//div[@role="tablist"]',
    #             Selector.XPATH)
    # tabs.setValue('Tab-23')

    # 卡片式
    tabs = Tabs(browser,
                '//section[@id="components-tabs-demo-card"]/section//div[@role="tablist"]',
                Selector.XPATH)
    tabs.setValue('Tab 3')

    # 可关闭
    tabs = Tabs(browser,
                '//section[@id="components-tabs-demo-editable-card"]/section//div[@role="tablist"]',
                Selector.XPATH)
    tabs.setValue('Tab 3')

